home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Other Langs / Tickle-4.0 (tcl) / tcl / expecTerm / expect.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-17  |  4.2 KB  |  122 lines  |  [TEXT/MPS ]

  1. /* expect.h - include file for using the expect library, libexpect.a
  2. ***************************************************************************** 
  3. expecTerm version 1.0 beta
  4. Mark Weissman
  5. Christopher Matheus
  6. Copyright 1992 by GTE Laboratories Incorporated.
  7.  
  8. Portions of this work are in the public domain.  Permission to use,
  9. copy, modify, and distribute this software and its documentation for
  10. any purpose and without fee is hereby granted, provided that the above
  11. copyright notice appear in all copies and that both the copyright
  12. notice and warranty disclaimer appear in supporting documentation, and
  13. that the names of GTE Laboratories or any of their entities not be
  14. used in advertising or publicity pertaining to distribution of the
  15. software without specific, written prior permission.
  16.  
  17. GTE disclaims all warranties with regard to this software, including
  18. all implied warranties of merchantability and fitness for a particular
  19. purpose, even if GTE Laboratories Incorporated knows about the
  20. purpose.  In no event shall GTE be liable for any special, indirect or
  21. consequential damages or any damages whatsoever resulting from loss of
  22. use, data or profits, whether in an action of contract, negligence or
  23. other tortuous action, arising out of or in connection with the use or
  24. performance of this software.
  25.  
  26. This code is based on and may include parts of Don Libes' expect code:
  27.   expect written by: Don Libes, NIST, 2/6/90
  28.   Design and implementation of expect was paid for by U.S. tax
  29.   dollars.  Therefore it is public domain.  However, the author and NIST
  30.   would appreciate credit if this program or parts of it are used.
  31. ******************************************************************************
  32.  
  33.  
  34. Written by: Don Libes, libes@cme.nist.gov, NIST, 12/3/90
  35. Modified by: Mark Weissman 9/92
  36.  
  37. Design and implementation of this program was paid for by U.S. tax
  38. dollars.  Therefore it is public domain.  However, the author and NIST
  39. would appreciate credit if this program or parts of it are used.
  40. */
  41.  
  42. #include <stdio.h>
  43. #include <setjmp.h>
  44.  
  45. /* return values */
  46. /* -1 is reserved for system errors */
  47. #define EXP_TIMEOUT            -2
  48. #define EXP_EOF                -3
  49.  
  50. struct exp_case {        /* case for expect command */
  51.     char *pattern;        /* if pattern not in list */
  52.     int value;        /* value to be returned upon match */
  53. };
  54.  
  55. #ifdef __cplusplus
  56. extern "C" {
  57. #endif
  58.  
  59. extern char *exp_match;
  60. extern int exp_match_max;        /* bytes */
  61. extern double exp_timeout;    /* seconds */    /* MDW: Mon Jun 22 14:40:24 1992 */
  62. extern int exp_pid;            /* process-id of spawned process */
  63. extern int exp_autoallocpty;        /* if TRUE, we do allocation */
  64. extern int exp_pty[2];            /* master is [0], slave is [1] */
  65. extern char *exp_stty;            /* args to stty to initialize pty */
  66. extern int exp_disconnected;        /* proc. disc'd from controlling tty */
  67.  
  68. extern jmp_buf exp_readenv;        /* for interruptable read() */
  69. extern int exp_reading;            /* whether we can longjmp or not */
  70.  
  71. extern int exp_logfile_all;
  72. extern int exp_loguser;
  73. extern int exp_is_debugging;
  74. extern FILE *exp_debugfile;
  75. extern FILE *exp_logfile;
  76.  
  77. /* support for Standard C and C++ prototypes */
  78. #ifdef __cplusplus
  79. #define EXP_PROTOTYPES
  80. #define EXP_VARARGS    ...
  81. #else
  82. #define EXP_VARARGS    , ...
  83. #ifdef __STDC__
  84. #define EXP_PROTOTYPES
  85. #endif
  86. #endif
  87.  
  88. #ifdef EXP_PROTOTYPES
  89. #define EXP_PROTO(x)    x
  90. #ifdef EXP_DEFINE_FNS
  91. /* when functions are really being defined, we have to use va_alist as arg */
  92. #define EXP_PROTOV(x)    va_alist
  93. #else
  94. #define EXP_PROTOV(x)    x
  95. #endif
  96. #else
  97. #define EXP_PROTO(x)    ()
  98. #define EXP_PROTOV(x)    ()
  99. #endif
  100.  
  101. /* Put double parens around macro args so they all look like a single arg */
  102. /* to preprocessor.  That way, don't need a different macro for functions */
  103. /* with a different number of arguments. */
  104.  
  105. extern int exp_disconnect EXP_PROTO(());
  106. extern FILE *exp_popen    EXP_PROTO((char *command));
  107.  
  108. #ifndef EXP_DEFINE_FNS
  109. extern int exp_spawnl    EXP_PROTOV((char *file EXP_VARARGS));
  110. extern int exp_expectl    EXP_PROTOV((int fd EXP_VARARGS));
  111. extern int exp_fexpectl    EXP_PROTOV((FILE *fp EXP_VARARGS));
  112. #endif
  113.  
  114. extern int exp_spawnv    EXP_PROTO((char *file, char *argv[]));
  115. extern int exp_expectv    EXP_PROTO((int fd, struct exp_case *cases));
  116. extern int exp_fexpectv    EXP_PROTO((FILE *fp, struct exp_case *cases));
  117.  
  118. #ifdef __cplusplus
  119. }
  120. #endif
  121.  
  122.